
import pyshark
from Godzilla import *
from urllib.parse import unquote
import re


def wr1(txt,kk):
    kk="aa"+str(kk)
    with open(kk,"wb") as f:
        f.write(txt)

bs64_str=re.compile(rb"[A-Za-z0-9+/]+={0,2}")
cap = pyshark.FileCapture('web.pcapng', display_filter="http.content_length")
# print(dir(cap[0].http))
tmp=[]
for c in cap:
    for i in c:
        try:
            #print(i.file_data)
            if "<" not in i.file_data:
                a=unquote(i.file_data).strip()
                tmp.append(a.encode())
        except:
            continue



decrypter = JAVA_AES_BASE64(pass_='password123', key='3c6e0b8a9c15224a')
k=0
print(len(tmp))
for i in tmp:
    k+=1
    print(k)
    #print(i)
    try:
        if b"pass" in i:
            data = decrypter.decrypt_req_payload(i)
            #print(data.decode('utf-8', 'ignore'))
            #print(data)
            #wr1(data,k)
        else:
            data = decrypter.decrypt_res_payload(i)
            #print(data.decode('utf-8', 'ignore'))
            #wr1(data,k)
            print(data)
    except:
        print("err:",i)
        continue